package com.vito.dcs.alarm.action;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.alibaba.dubbo.config.annotation.Reference;
import com.vito.base.authoriza.action.BaseAction;
import com.vito.base.authoriza.cache.SessionMap;
import com.vito.base.authoriza.model.UserModel;
import com.vito.base.model.DataGrid;
import com.vito.base.model.Result;
import com.vito.base.tools.I18nResMsg;
import com.vito.base.util.Validata;
import com.vito.dcs.alarm.model.RollerAlarmModel;
import com.vito.dcs.alarm.service.RollerAlarmService;
import com.vito.dcs.process.model.PavingProcessModel;

@Controller
@RequestMapping("/dcs/alarm")
public class RollerAlarmAction extends BaseAction{

	private static final Logger log = LoggerFactory.getLogger(RollerAlarmAction.class);
	
	@Reference
	private RollerAlarmService rollerAlarmService;
	
	@RequestMapping("/saveRollerAlarm")
	@ResponseBody
	public Result saveRollerAlarm(RollerAlarmModel rollerAlarmModel){
		Result res = new Result();
		UserModel obj = SessionMap.getObj();
		
		if(obj == null || Validata.isNullOrEmpty(obj.getUserId())){
			res.setCode(Result.CODE_LOGIN_REQUIRE);
			res.setMsg(I18nResMsg.MSG_LOGIN_NEED());
			return res;
		}
		try {
			rollerAlarmModel.setUpdateUser(obj.getUserId());
			rollerAlarmService.saveRollerAlarm(rollerAlarmModel);
			res.setCode(Result.CODE_OK);
			res.setMsg(I18nResMsg.SAVESUC());
		} catch (Exception e) {
			res.setCode(Result.CODE_ERROR);
			res.setMsg(I18nResMsg.SAVEERR());
			log.error(I18nResMsg.SAVEERR(), e);
		}
		return res;
	}
	@RequestMapping("/queryRollerAlarmBySectionId")
	@ResponseBody
	public Result queryRollerAlarmBySectionId(RollerAlarmModel rollerAlarmModel){
		Result res = new Result();
		try {
			RollerAlarmModel queryRollerAlarmBySectionId = rollerAlarmService.queryRollerAlarmBySectionId(rollerAlarmModel);
			res.setCode(Result.CODE_OK);
			res.setData(queryRollerAlarmBySectionId);
		} catch (Exception e) {
			res.setCode(Result.CODE_ERROR);
			res.setMsg(I18nResMsg.SAVEERR());
			log.error(I18nResMsg.SAVEERR(), e);
		}
		return res;
	}
	
}
